/*
 * @Author: szx
 * @Date: 2021-12-22 15:27:27
 * @LastEditTime: 2021-12-22 15:36:53
 * @Description:
 * @FilePath: \leetcode\400-499\404\404.js
 */
/**
 * Definition for a binary tree node.
 * function TreeNode(val, left, right) {
 *     this.val = (val===undefined ? 0 : val)
 *     this.left = (left===undefined ? null : left)
 *     this.right = (right===undefined ? null : right)
 * }
 */
/**
 * @param {TreeNode} root
 * @return {number}
 */
var sumOfLeftLeaves = function (root) {
    if (root == null) return 0;
    // const lenLeft = sumOfLeftLeaves(root.left);
    // const lenRight = sumOfLeftLeaves(root.right);
    if (root.left && !root.left.left && !root.left.right) {
        return root.left.val + sumOfLeftLeaves(root.right);
    }
    return sumOfLeftLeaves(root.left) + sumOfLeftLeaves(root.right);
};
